// JavaScript Document
function Inint_AJAX() 
{
	try 
	{ 
		return new ActiveXObject("Msxml2.XMLHTTP");  
	} 
	catch(e) 
	{} //IE
	try 
	{ 
		return new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	catch(e) {} //IE
	try 
	{ 
		return new XMLHttpRequest(); 
	} catch(e) {} //Native Javascript
	alert("XMLHttpRequest not supported");
	return null;
};
		
function changeDistrict(district,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				document.getElementById(district).innerHTML=req.responseText; 
							//alert(req.responseText);
			} 
		}
	};
	req.open("post", "dropdown_q2.php?data="+district+"&val="+val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}
window.onLoad=changeDistrict('district',-1);   



function changeBlock(block,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		document.getElementById('blockLoader').innerHTML="<img src='images/ajax-loader.gif' />";
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				document.getElementById('blockLoader').innerHTML=" ";
				document.getElementById(block).innerHTML=req.responseText; 
							//alert(req.responseText);
			} 
		}
	};
	req.open("post", "dropdown_q2.php?data="+block+"&val="+val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}


function changeTehsil(tehsil,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		document.getElementById('tehsilLoader').innerHTML="<img src='images/ajax-loader.gif' />";
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				document.getElementById('tehsilLoader').innerHTML=" ";
				document.getElementById(tehsil).innerHTML=req.responseText; 
							//alert(req.responseText);
			} 
		}
	};
	req.open("post", "dropdown_q2.php?data="+tehsil+"&val="+val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}



function changePanchayat(panchayat,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		document.getElementById('panchayatLoader').innerHTML="<img src='images/ajax-loader.gif' />";
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				document.getElementById('panchayatLoader').innerHTML=" "; 
				document.getElementById(panchayat).innerHTML=req.responseText; 
							//alert(req.responseText);
			} 
		}
	};
	req.open("post", "dropdown_q2.php?data="+panchayat+"&val="+val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}



function changeVillage(village,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		document.getElementById('villageLoader').innerHTML="<img src='images/ajax-loader.gif' />";
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				document.getElementById('villageLoader').innerHTML=" ";
				document.getElementById(village).innerHTML=req.responseText; 
							//alert(req.responseText);
			} 
		}
	};
	req.open("post", "dropdown_q2.php?data="+village+"&val="+val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}




function changeHabit(habit,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				document.getElementById(habit).innerHTML=req.responseText; 
							//alert(req.responseText);
			} 
		}
	};
	req.open("post", "dropdown_q2.php?data="+habit+"&val="+val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}


function changeCensusCode(cvc,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
		if (req.readyState==4)
		{
			if (req.status==200) 
			{
				document.getElementById(cvc).innerHTML=req.responseText; 
							//alert(req.responseText);
			} 
		}
	};
	req.open("post", "dropdown_q2.php?data="+cvc+"&val="+val); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}


function changeFormId(form,form_id,val) 
{
	var req = Inint_AJAX();
	req.onreadystatechange = function () 
	{ 
	   //alert(req.readyState);
		if (req.readyState == 4)
		{
			//alert(req.status);
			if (req.status == 200) 
			{
				document.getElementById(form_id).innerHTML = req.responseText; 
			}
		}
	};
	var dis_name = form.district.options[form.district.selectedIndex].text;
	req.open("post", "dropdown_q2.php?dist="+dis_name+"&data="+form_id+"&val="+val);
	//alert("dropdown.php?dist="+dis_name+"&data="+form_id+"&val="+val);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	req.send(null); 
}
